package com.bw.medical.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bw.medical.entity.DockerLevelEntity;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bw.common.utils.PageUtils;
import com.bw.common.utils.Query;

import com.bw.medical.dao.PatientDao;
import com.bw.medical.entity.PatientEntity;
import com.bw.medical.service.PatientService;


@Service("patientService")
public class PatientServiceImpl extends ServiceImpl<PatientDao, PatientEntity> implements PatientService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        IPage<PatientEntity> page = this.page(
                new Query<PatientEntity>().getPage(params),
                new QueryWrapper<PatientEntity>()
        );
        return new PageUtils(page);
    }

    @Override
    public IPage<DockerLevelEntity> getLists(Map<String, Object> params) {
        String patientPackname=null;
        if (!params.get("patientPackname").toString().equals(""))
        {
            patientPackname=params.get("patientPackname").toString();
        }
        String patientName=null;
        if (!params.get("patientName").toString().equals(""))
        {
            patientName=params.get("patientName").toString();
        }
        Page<DockerLevelEntity> page = new Page<>(Integer.valueOf(params.get("page").toString()), Integer.valueOf(params.get("limit").toString()));
        return baseMapper.getLists(page,patientPackname,patientName);
    }

    @Override
    public PatientEntity login(PatientEntity patientEntity) {
        PatientEntity patientTel = baseMapper.selectOne(new QueryWrapper<PatientEntity>().eq("patient_tel", patientEntity.getPatientTel()));
        if (patientTel!=null){
            if (patientTel.getPatientPwd().equals(patientEntity.getPatientPwd())){
                return patientTel;
            }
        }
        return null;
    }

}